import React from "react";
class Child extends React.PureComponent {
    render() {
        console.log("子组件渲染了 render ");
        return (
            <div>
                Child
                <button onClick={this.props.onClick}>点击子组件</button>
            </div>
        );
    }
}

class App extends React.Component {
    state = {
        name: "我是传智播客",
    };
    handleClick = () => {
        console.log("我点击了子组件的按钮");
    };
    render() {
        return (
            <div>
                <button
                    onClick={() => {
                        this.setState({
                            name: "我是传智播客",
                        });
                    }}>
                    setName
                </button>
                <Child
                    name={this.state.name}
                    // 每次render都会生成一个新的函数
                    // onClick={() => {
                    //     console.log("我点击了子组件的按钮");
                    // }}></Child>
                    onClick={this.handleClick}></Child>
            </div>
        );
    }
}

export default App;
